﻿import React from 'react';
import './App.css';
// import { Button } from 'antd-mobile';

// 引入路由组件
import {BrowserRouter as Router, Route, Switch, Redirect} from 'react-router-dom';
// 引入首页组件
import Home from './views/layout/index.js'
// 引入城市列表组件
import CityList from './views/city/index.js'
// 地图找房
import TestMap from './views/map/index.js'
// 房源详情
import HouseDetail from './views/detail/index.js'
// 登录页面
import Login from './views/login/index.js'
// 登录拦截
import AuthCheck from './components/AuthCheck/index.js'
// 房源列表
import Rent from './views/rent/index.js'
// 添加房源
import Add from './views/rent/Add/index.js'
// 小区地址
import Search from './views/rent/Search/index.js'

function NotMatch() {
    return <div>405</div>
}

class App extends React.Component {
    render() {
        return (
            <Router>
                {/*配置全局路由映射*/}
                <Switch>
                    <Redirect exact from='/' to='/Home'/>
                    {/*登录组件*/}
                    <Route path='/login' component={Login}/>
                    {/*主页组件*/}
                    <AuthCheck path='/home' component={Home}/>
                    {/*房源详情*/}
                    <Route path='/detail' component={HouseDetail}/>
                    {/*城市列表组件*/}
                    <Route path='/citylist' component={CityList}/>
                    {/*地图找房组件*/}
                    <Route path='/map' component={TestMap}/>
                    {/*房源列表*/}
                    <AuthCheck exact path='/rent' component={Rent}/>
                    {/*添加房源*/}
                    <AuthCheck path='/rent/add' component={Add}/>
                    {/*小区地址*/}
                    <AuthCheck path='/rent/search' component={Search}/>
                    {/*404未匹配组件*/}
                    <Route component={NotMatch}/>
                </Switch>
            </Router>
        );
    }
}

export default App;
